package com.app;

import android.content.Context;
import android.support.multidex.MultiDexApplication;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

import com.baidu.mapapi.SDKInitializer;
import com.app.model.bean.Size;
import com.app.utils.UniversualImageLoaderUtils;
import com.tencent.bugly.Bugly;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;


public class Application extends MultiDexApplication {

    private static final String LOG_TAG = Application.class.getSimpleName();

    public static Application instance;


    public Application() {
        instance = this;
    }

    private Size screenSize;

    private UMShareListener mShareListener;

    public ShareAction shareAction;


    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
//        //异常处理
//        CrashHandler crashHandler = CrashHandler.getInstance();
//        crashHandler.init(getApplicationContext());
        Bugly.init(getApplicationContext(), "8674d2cfb4", false);

        UniversualImageLoaderUtils.initImageLoader(getApplicationContext());


        MobclickAgent.setDebugMode(true);
        // 友盟分享功能初始化
        UMShareAPI.get(this);
        SDKInitializer.initialize(getApplicationContext());

    }

    //各个平台的配置，建议放在全局Application或者程序入口
    {
        // 友盟自带
//        PlatformConfig.setWeixin("wxdc1e388c3822c80b", "3baf1193c85774b3fd9d18447d76cab0");
        // 个人申请
        PlatformConfig.setWeixin("wx627b7dbf91de3e8a", "b159419c909168afb1ec9a08e3ce857e");
//        PlatformConfig.setWeixin("wx627b7dbf91de3e8a", "a32b2a37bce3a8f78af7eaffc136085e");
//        //豆瓣RENREN平台目前只能在服务器端配置
//        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad","http://sns.whalecloud.com");
//        PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
//        PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
//        PlatformConfig.setAlipay("2015111700822536");
//        PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
//        PlatformConfig.setPinterest("1439206");
//        PlatformConfig.setKakao("e4f60e065048eb031e235c806b31c70f");
//        PlatformConfig.setDing("dingoalmlnohc0wggfedpk");
//        PlatformConfig.setVKontakte("5764965","5My6SNliAaLxEm3Lyd9J");
//        PlatformConfig.setDropbox("oz8v5apet3arcdy","h7p2pjbzkkxt02a");

    }


    /**
     * 获取屏幕尺寸大小
     */
    public Size getScreentSize() {
        if (screenSize == null) {
            WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
            Display display = windowManager.getDefaultDisplay();
            DisplayMetrics outMetrics = new DisplayMetrics();
            display.getMetrics(outMetrics);
            screenSize = new Size(outMetrics.widthPixels, outMetrics.heightPixels);
        }
        return screenSize;
    }

}
